<template>
  <div id="toast" v-show="isShow">
    <div>{{ message }}</div>
  </div>
</template>
<script>
export default {
  name: "Toast",
  data() {
    return {
      isShow: false,
      message: "",
    };
  },
  methods: {
    show(message, duration = 2000) {
      this.isShow = true;
      this.message = message;
      setTimeout(() => {
        this.isShow = false;
        this.message = "";
      }, duration);
    },
  },
};
</script>
<style scoped>
#toast{
  position: absolute;
  left: 50%;
  top: 46%;

  transform: translate(-50%,-50%);

  font-size: 16px;
  padding: 5px 10px;
  background-color: rgb(0, 0, 0,0.5);
  color: #fff;

  border-radius: 5px;
  z-index: 99;
}
</style>
